//
//  ILeader.swift
//  ResponsibilityChainDemo
//
//  Created by aron on 2017/6/3.
//  Copyright © 2017年 aron. All rights reserved.
//

import Foundation

class ILeader: NSObject {
    var nextLeader: ILeader?
    
    func handleExpense(expense: Expense) {
        if expense.price <= self.limit() {
            // 当前领导处理
            self.doHandleExpense(expense: expense)
        } else {
            // 下一个领导处理
            self.nextLeader?.handleExpense(expense: expense)
        }
    }
    
    func doHandleExpense(expense: Expense) {
        // 子类重写
    }
    
    func limit() -> Int {
        return 0;
    }
}
